package com.it.server.controller.user;

import com.it.common.result.PageResult;
import com.it.pojo.DTO.PageDTO;
import com.it.pojo.Entity.Merchant;
import com.it.pojo.VO.MerchantDetailVO;
import com.it.pojo.VO.MerchantListVO;
import com.it.common.result.Result;
import com.it.server.service.MerchantService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/user/merchant")
@Tag(name = "商户接口")
@Slf4j
public class MerchantController {
    @Autowired
    private MerchantService merchantService;
//    @GetMapping("/list")
//    public Result<List<MerchantListVO>> list(){
//        log.info("查询商户列表");
//        List<MerchantListVO> list = merchantService.list();
//        return Result.success(list);
//    }
    @GetMapping("/detail/{id}")
    @Operation(summary="查询商户详情")
    public Result<MerchantDetailVO> detail(@PathVariable Integer id){
        log.info("查询商户详情");
        MerchantDetailVO merchantDetailVO = merchantService.detail(id);
        return Result.success(merchantDetailVO);
    }
    @PostMapping("/list/query")
    @Operation(summary="分页查询商户列表")
    public PageResult<MerchantListVO> query(@RequestBody PageDTO pageDTO){
        log.info("查询商户列表");
        PageResult<MerchantListVO> list = merchantService.query(pageDTO.getPage(),pageDTO.getPageSize());
        return list;
    }
    @GetMapping("/list/category/{categoryId}")
    @Operation(summary="查询商户分类列表")
    public Result<List<MerchantListVO>> listCategory(@RequestParam Integer categoryId){
        log.info("查询商户分类列表");
        List<MerchantListVO> list = merchantService.listCategory(categoryId);
        return Result.success(list);
    }
}
